package com.ruoyi.api.domain;

/**
 * 订单表
 *
 * @author 寻觅
 * @since 2025-06-04
 */

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.DecimalMin;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 订单实体类
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@TableName("orders")
public class Order {

    @TableId(type = IdType.ASSIGN_UUID) // 自动生成不带横线的UUID
    private String orderId;

    /**
     * 订单状态（1待支付 2已支付 3待发货 4已发货 5已完成 6已取消）
     */
    @NotNull(message = "订单状态不能为空")
    @Min(value = 1, message = "订单状态值无效")
    private Integer orderStatus;

    @NotNull(message = "用户ID不能为空")
    private Long userId;

    @NotBlank(message = "用户名称不能为空")
    private String userName;

    @NotNull(message = "商家ID不能为空")
    private Integer merchantId;

    @NotBlank(message = "商家名称不能为空")
    private String merchantName;

    /**
     * 支付方式（1微信 2 支付宝 3银行卡 4本地钱包）
     */
    @NotNull(message = "支付方式不能为空")
    @Min(value = 1, message = "支付方式值无效")
    private Integer paymentType;

    @NotNull(message = "商品ID不能为空")
    private String productId;


    @NotBlank(message = "商品数量不能为空")
    private Integer productQuantity;

    private String productQuantityOne;

    @NotNull(message = "商品小计不能为空")
    @DecimalMin(value = "0.01", message = "商品小计不能小于0.01")
    private BigDecimal productSubtotal;


    @NotNull(message = "收获地址ID不能为空")
    private Integer addressId;

    private LocalDateTime receiptTime;

    private LocalDateTime paymentTime;

    private LocalDateTime createTime;

    private LocalDateTime dispatchTime;

    private LocalDateTime expireTime;

    private String remark;

    /**
     * 删除标志（0代表存在 2代表删除）
     */
    @Builder.Default
    private String delFlag = "0";

    private String createBy;

    private String updateBy;

    private LocalDateTime updateTime;
}
